/* 
 * Copyright (c)	Insighten Intelligent Equipment co.,LTD
 * 
 *  Use of this software is controlled by the terms and conditions found
 *  in the license agreement under which this software has been supplied.
 * 
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include "rwbuf.h"

char *mem_alloc(int size)
{
	printf("use my memory alloc!\n");

	return calloc(size, 1);
}

int *mem_free(char *mem)
{
	printf("use my memory free!\n");

	free(mem);

	return 0;
}

int main (int argc, char *argv[])
{
	RwBuf *buf = NULL;

	char data[1024]={1};

	buf = buf_new((FunMemAlloc)mem_alloc, (FunMemFree)mem_free);

	if (buf == NULL) {
		printf("buf_new error.\n");
		exit(1);
	}
	buf_init(buf, 1024);

	memmove(buf->mem, data, 1024);

	printf("total size = %d\n", buf->totalsize);

	buf_destroy(buf);

	return 0;
}
